import _ from 'lodash'
import merchant from './merchant/index' // 商户
import user from './user/index' // 用户
import product from './product/index' // 产品
import content from './content/index' // 内容
import promotion from './promotion/index' // 推广
import order from './order/index' // 订单
import finance from './finance/index' // 财务
import permit from './permit/index' // 权限
import setting from './setting/index' // 设置

let list = [
  {
    path: '/index',
    name: 'pc_index',
    component: resolve => require(['../components/page/Index.vue'], resolve),
    meta: {
      title: '首页', login: true, isDetail: true, model: '首页', isStart: true 
    }
  },
]
let base = [...merchant,...user,...product,...content,...promotion,...order,...finance,...permit,...setting,...list]

export default new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: '/merchant'
    },
    {
      path: '/home',
      component: resolve => require(['../components/common/home.vue'], resolve),
      meta: {
        title: 'home'
      },
      children: base
    },
    {
      path: '/login',
      name: 'login',
      component: resolve => require(['../components/page/Login.vue'], resolve),
      meta: {
        title: '登录', login: false,  model: '登录'
      }
    },
    {
      path: '/register',
      name: 'register',
      component: resolve => require(['../components/page/register.vue'], resolve),
      meta: {
        title: '注册', login: false,  model: '注册'
      }
    },
    {
      path: '/404',
      component: resolve => require(['../components/page/404.vue'], resolve),
      meta: {
        title: '404'
      }
    },
  ]
})
